<?php if (!isset($v_sval)) exit;
	$account_pass_current = (isset($_REQUEST["account_pass_current"])) ? $_REQUEST["account_pass_current"] : '';
	$account_pass_new = (isset($_REQUEST["account_pass"])) ? $_REQUEST["account_pass"] : '';
	$account_pass_retype = (isset($_REQUEST["account_pass_retype"])) ? $_REQUEST["account_pass_retype"] : '';
	$account_email_new = (isset($_REQUEST["account_email"])) ? $_REQUEST["account_email"] : '';
	$account_email_retype = (isset($_REQUEST["account_email_retype"])) ? $_REQUEST["account_email_retype"] : '';
	$groom_name_new = (isset($_REQUEST["groom_name"])) ? $_REQUEST["groom_name"] : '';
	$bride_name_new = (isset($_REQUEST["bride_name"])) ? $_REQUEST["bride_name"] : '';	
	$wedding_date_new = (isset($_REQUEST["wedding_date"])) ? $_REQUEST["wedding_date"] : date("Y-m-d");	
	$wedding_location_new = (isset($_REQUEST["wedding_location"])) ? $_REQUEST["wedding_location"] : '';
	
	$sql = 'UPDATE TB_ACCOUNT SET ';
	$arr_update = array();
	if ( isset($user_id) && $user_id != 0 ){
		
		$rs = getSingerAccount($user_id);
		if ( $arr = mysql_fetch_assoc($rs) ){
			$account_email 				= $arr['ACCOUNT_EMAIL'];
			$account_pass				= $arr['ACCOUNT_PASS'];
			$account_bride_name 		= $arr['ACCOUNT_BRIDE_NAME'];
			$account_groom_name 		= $arr['ACCOUNT_GROOM_NAME'];
			$account_wedding_date 		= $arr['ACCOUNT_WEDDING_DATE'];
			$account_wedding_location 	= $arr['ACCOUNT_WEDDING_LOCATION'];

			if ( $account_pass_current != ''){
				if ( md5($account_pass_current) != $account_pass ){
					$_SESSION['error_pass'] = _ERROR_MSG_PASSWORD_NOT_CORRECT;
				}else{
					if ( $account_pass_new == $account_pass_retype ){
						$arr_update[] = ' ACCOUNT_PASS = "' .md5($account_pass_new) .'" ';
						$_SESSION['error_pass'] = '';
					}
				}
			}

			if ( $account_email_new != '' ){
				if ( $account_email_new != $account_email_retype ){
					$_SESSION['error_email'] = _ERROR_MSG_ACCOUNT_EMAIL_NOT_MATCH;
				}else{
					if ( isAccountEmailExists($account_email_new) ){
						$_SESSION['error_email'] = _ERROR_MSG_ACCOUNT_EMAIL_DUPLICATE;
					}
					else{
						$arr_update[] = ' ACCOUNT_EMAIL = "' .$account_email_new .'" ';
						$_SESSION['error_email'] = '';
					}
				}
			}

			if ( $bride_name_new != ''){
				$arr_update[] = ' ACCOUNT_BRIDE_NAME = "'.mysql_real_escape_string($bride_name_new).'" ';
			}

			if ( $groom_name_new != ''){
				$arr_update[] = ' ACCOUNT_GROOM_NAME = "'.mysql_real_escape_string($groom_name_new).'" ';
			}

			if ( $wedding_date_new != ''){
				$arr_update[] = ' ACCOUNT_WEDDING_DATE = "'.convertDatetoSQLDate($wedding_date_new).'" ';
			}

			if ( $wedding_location_new != ''){
				$arr_update[] = ' ACCOUNT_WEDDING_LOCATION = "'.mysql_real_escape_string($wedding_location_new).'" ';
			}
		}

		if ( sizeof($arr_update) ){
			$sql .= implode(',', $arr_update) . ' WHERE ACCOUNT_ID = ' . $user_id;
			mysql_query($sql) or die(mysql_error());
		}
	}

	redir('?a=ACC&acc=USER&user=INFO');
?>